package com.googlecode.stemwijzer.shared.serializer.rest.json;

import com.google.gwt.json.client.JSONValue;

/**
 * The Interface JsonCodec.
 * 
 * @param <T>
 *            the < t>
 * @author jeroen.brosens
 */
public interface JsonCodec<T> {

	/**
	 * Gets the identifier.
	 * 
	 * @return the identifier, which should match the declared instance identifier.
	 */
	public String getIdentifier();

	/**
	 * Encode.
	 * 
	 * @param type
	 *            the type
	 * 
	 * @return the jSON value
	 * 
	 * @throws EncodeException
	 *             the encode exception
	 */
	public JSONValue encode(T type) throws EncodeException;

	/**
	 * Decode.
	 * 
	 * @param value
	 *            the json value
	 * 
	 * @return the t
	 * 
	 * @throws DecodeException
	 *             the decode exception
	 */
	public T decode(JSONValue value) throws DecodeException;
}
